# Maintainer: Naveen M K naveen521kk@gmail.com

_pyname=glcontext
_realname=glcontext
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.3.4
pkgrel=1
pkgdesc='Portable OpenGL Context (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/moderngl/glcontext"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz"
        "0001-workaround-for-clang.patch")
sha256sums=('537cd5113f7a5c17094dee50107587adeaea01d4854407bdab8e3bcd808e0bc6'
            'e19e4d500b54d47305b09dfbf816bb679487833cc22f09a6a67337ee3c805e69')

prepare() {
  cd "${srcdir}/${_pyname//_/-}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-workaround-for-clang.patch"
  cd ../

  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname//_/-}-${pkgver}" "python-build-${CARCH}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
